A programmatically-created verifier with custom verification and applicability logic.
Object Model
Syntax
Type Parameters
- T
- the Type of object being verified
Example
C# | Copy Code |
---|
private DelegateVerifier SampleDelegateVerifier() {
// A simple example adding a delegate verifier to ensure that Employee
// BirthDate falls before HireDate.
// Apply verifier only when have data for both properties.
ApplicabilityConstraint<Employee> constraint = (emp, trigger, context) => {
return emp.HireDate.HasValue && emp.BirthDate.HasValue ?
VerifierApplicability.Yes : VerifierApplicability.InsufficientData;
};
// Define the verification performed - BirthDate must precede HireDate
VerifierCondition<Employee> condition = (emp, trigger, context) => {
return new VerifierResult(emp.BirthDate < emp.HireDate);
};
var errorMessage = "Must be born before hired";
// Create the verifier. Execute only after set and on instance.
var v = new DelegateVerifier<Employee>(errorMessage, constraint, condition);
v.VerifierOptions.ExecutionModes = VerifierExecutionModes.InstanceAndOnAfterSetTriggers;
// Add triggers - setters for HireDate and BirthDate properties will trigger.
v.AddTriggers(Employee.PropertyMetadata.HireDate.Name, Employee.PropertyMetadata.BirthDate.Name);
return v;
} |
Remarks
Inheritance Hierarchy
Requirements
Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family
See Also